﻿cmake_minimum_required(VERSION 3.5.0)
project(DP100 VERSION 0.1.0 LANGUAGES C CXX)

set(CMAKE_CXX_STANDARD_REQUIRED True)  
# 为MSVC编译器添加/clr标志以启用CLR支持  
if(MSVC)
    add_definitions(-D_USRDLL)  
    add_compile_options(/clr)  
endif()

include_directories(./export)
aux_source_directory(./Sources SRC_LIST)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})

add_library(${PROJECT_NAME} SHARED ${SRC_LIST})

add_subdirectory(TEST)

add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
                    COMMAND ${CMAKE_COMMAND} -E copy
                    $<TARGET_FILE:${PROJECT_NAME}>  # 源文件（可执行文件路径）
                    ${PROJECT_SOURCE_DIR}/export/$<TARGET_FILE_NAME:${PROJECT_NAME}>   # 目标目录
                    COMMENT "Copy $<TARGET_FILE_NAME:${PROJECT_NAME}> to ${PROJECT_SOURCE_DIR}/export/$<TARGET_FILE_NAME:${PROJECT_NAME}>"
                    
                    COMMAND ${CMAKE_COMMAND} -E copy
                    $<TARGET_IMPORT_FILE:${PROJECT_NAME}>  # 源文件（可执行文件路径）
                    ${PROJECT_SOURCE_DIR}/export/$<TARGET_IMPORT_FILE_NAME:${PROJECT_NAME}>   # 目标目录
                    COMMENT "Copy $<TARGET_IMPORT_FILE_NAME:${PROJECT_NAME}> to ${PROJECT_SOURCE_DIR}/export/$<TARGET_IMPORT_FILE_NAME:${PROJECT_NAME}>"

                    COMMAND ${CMAKE_COMMAND} -E copy
                    ${PROJECT_SOURCE_DIR}/export/ATK-DP100DLL.dll
                    ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$<CONFIG>/ATK-DP100DLL.dll   # 目标目录
                    COMMENT "Copy ${PROJECT_SOURCE_DIR}/export/ATK-DP100DLL.dll to ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$<CONFIG>/ATK-DP100DLL.dll")